# 数据类型
print('----------------数据类型----------------------')
a = 5
print(type(a))   # <class 'int'>
print(type(10))  # <class 'int'>
b=6.18
print(type(b))  # <class 'float'>
c='222'
d='hahaha'
print(type(c))  # <class 'str'>
print(type(d))  # <class 'str'>
e=True
print(type(e))  # <class 'bool'>
# 类型转换
print('--------------类型转换-整型------------------------')
x = 10
print(str(x),type(str(x)))  # 10 <class 'str'>
print(float(x),type(float(x)))  # 10.0 <class 'float'>
print(bool(x),type(bool(x)))    # True <class 'bool'>
print('----------------类型转换-字符串（非数字）----------------------')
y = 'abc'
# print(int(y),type(int(y)))  # ValueError: invalid literal for int() with base 10: 'abc'
# print(float(y),type(float(y)))  # ValueError: could not convert string to float: 'abc'
print(bool(y),type(bool(y)))    # True <class 'bool'>
print('----------------类型转换-字符串（数字）----------------------')
z = '100'
print(int(z),type(int(z)))  # 100 <class 'int'>
print(float(z),type(float(z)))  # 100.0 <class 'float'>
print(bool(z),type(bool(z)))    # True <class 'bool'>
print('----------------类型转换-浮点数----------------------')
m = 10.68
print(int(m),type(int(m)))  # 10 <class 'int'>
print(str(m),type(str(m)))  # 10.68 <class 'str'>
print(bool(m),type(bool(m)))    # True <class 'bool'>
print('----------------类型转换-布尔----------------------')
n = True
print(int(n),type(int(n)))  # 1 <class 'int'>
print(str(n),type(str(n)))  # True <class 'str'>
print(float(n),type(float(n)))  # 1.0 <class 'float'>

# 布尔值
'''
    假值：0，空字符串("")
    真值：非0，非空字符串("")
'''
print(bool(1))  # True
print(bool(0))  # False
print(bool(""))  # False
print(bool(" "))    # True
print(bool("0"))    # True
print(bool("abc"))  # True

